package com.xx.controller.xunyou.app;

import com.xx.springBootUtil.result.JsonResult;
import com.xx.xunyou.entity.item.chizhuzaixiang.vo.ChizhuzaixiangVo;
import com.xx.xunyou.entity.item.vo.IndexVo;
import com.xx.xunyou.entity.item.vo.XunyouItemTypeTopAndSonsVo;
import com.xx.xunyou.entity.item.xiangcunbanshouli.vo.XiangcunbanshouliBaseVo;
import com.xx.xunyou.entity.item.xiaochenggushiduo.vo.XiaochenggushiduoVo;
import com.xx.xunyou.entity.item.youlezaixiangcun.vo.YoulezaixiangcunVo;
import com.xx.xunyou.service.*;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: xunyou-parent
 * @author: zhl
 * @create: 2019-04-30
 **/
@Api(value = "API - IndexController", description = "首页")
@RestController
public class IndexController {

    @Autowired
    private AreaService areaService;

    @Autowired
    private ChizhuzaixiangService chizhuzaixiangService;

    @Autowired
    private XiangcunbanshouliService xiangcunbanshouliService;

    @Autowired
    private XiaochenggushiduoService xiaochenggushiduoService;

    @Autowired
    private YoulezaixiangcunSerivce youlezaixiangcunSerivce;

    @Autowired
    private ItemTypeService itemTypeService;

    /**
     * 首页
     * @return
     */
    @ApiOperation(value = "首页", notes = "首页", response = IndexVo.class)
    @ApiImplicitParams({
//            @ApiImplicitParam(name = "token", value = "用户验证TOKEN - Y", dataType = "string", required = true, paramType = "query"),
    })

    @ApiResponses({@ApiResponse(code = 200, message = "")})
    @RequestMapping(value = "/index", method = RequestMethod.POST)
    public JsonResult accountInfo() {
        //查询导航栏
        List<XunyouItemTypeTopAndSonsVo> typeTops = itemTypeService.queryTopToAPPIndex();
        Map<String,Object> map = new HashMap<>();
        map.put("start", 0);
        map.put("pageIndex", 1);
        map.put("pageSize", 6);
        //吃住在乡
        List<ChizhuzaixiangVo> chizhuzaixiangs = chizhuzaixiangService.queryListToAPPIndex(map);

        //乡村伴手礼
        List<XiangcunbanshouliBaseVo> xiangcunbanshoulis = xiangcunbanshouliService.queryListToAPPIndex(map);

        //小城故事多
        List<XiaochenggushiduoVo> xiaochenggushiduos = xiaochenggushiduoService.queryListToAPPIndex(map);

        //游乐在乡村
        List<YoulezaixiangcunVo> youlezaixiangcuns = youlezaixiangcunSerivce.queryListToAPPIndex(map);
        //周末去哪儿

        IndexVo indexVo = new IndexVo();
        indexVo.setTypeTops(typeTops);
        indexVo.setChizhuzaixiangs(chizhuzaixiangs);
        indexVo.setXiangcunbanshoulis(xiangcunbanshoulis);
        indexVo.setXiaochenggushiduos(xiaochenggushiduos);
        indexVo.setYoulezaixiangcuns(youlezaixiangcuns);
        return new JsonResult(indexVo);
    }
}
